<template>
  <div class="nameplate_module">
    <header class="nameplate-header">
      <h4>气体超声流量计</h4>
      <div class="image-left">
        <img src="@/assets/template/nameplate_left.png" width="60" />
        <span>{{ template_data.approval_type }}</span>
      </div>
      <div class="image-right">
        <img src="@/assets/template/nameplate_right.png" width="60" />
        <span>{{ template_data.explosion_proof }}</span>
      </div>
    </header>
    <section class="nameplate-message">
      <div class="column">
        <div v-for="tem in pre_template" :key="tem" class="row">
          <span class="title">{{ tem }}:</span>
          <span class="value">{{ template_data[tem] }}</span>
        </div>
      </div>
      <div class="column">
        <div class="qrcode">
          <canvas ref="qrcode" class="qrcode" />
        </div>
        <div v-for="tem in next_template" :key="tem" class="row">
          <span class="title">{{ tem }}:</span>
          <span class="value">{{ template_data[tem] }}</span>
        </div>
      </div>
    </section>
    <footer class="nameplate-footer">footer</footer>
  </div>
</template>

<script lang="ts">
import { Dictionary } from '@/interface/Basic'
import Vue from 'vue'
import { Component } from 'vue-property-decorator'
@Component
class NameplateModule extends Vue {
  cur_template: string[] = [
    '准确度等级',
    '规格型号',
    '接管内径',
    '工作压力',
    '流量范围',
    '介质温度',
    '环境温度',
    '出厂编号',
    '防护等级',
    '防爆等级',
    '制造日期'
  ]
  template_data: Dictionary<string> = {
    approval_type: '',
    explosion_proof: ''
  }
  get pre_template() {
    return this.cur_template.slice(0, 8)
  }
  get next_template() {
    return this.cur_template.slice(8)
  }
}
export default NameplateModule
</script>

<style lang="less" scoped>
.nameplate_module {
  width: 600px;
  height: 425px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  padding: 20px 10px;
  border: solid 1px #f3f3f3;
  background-color: #ffffff;
  .nameplate-header {
    box-sizing: border-box;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    h4 {
      margin: 0;
      font-size: 24px;
      font-family: '黑体';
    }
    .image-left,
    .image-right {
      display: flex;
      flex-direction: column;
      align-items: center;
      font-size: 12px;
    }
  }
  .nameplate-message {
    flex: 1;
    position: relative;
    box-sizing: border-box;
    padding: 0 20px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    .column {
      flex: 1;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: flex-start;
      .row {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 28px;
        margin-bottom: 10px;
        .title {
          width: 35%;
        }
        .value {
          flex: 1;
          text-align: right;
        }
      }
      .qrcode {
        width: 100%;
        height: 120px;
        display: flex;
        align-items: center;
        justify-content: center;
        .qrcode {
          width: 120px;
        }
      }
    }
    .column:first-child {
      margin-right: 40px;
    }
  }
  .nameplate-footer {
    margin: 0;
    font-size: 24px;
    font-family: '黑体';
  }
}
</style>
